package com.example.myapplication3;

import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // 检查登录状态
        TokenManager tokenManager = new TokenManager(this);
        if (!tokenManager.isLoggedIn()) {
            // 未登录则返回登录页
            startActivity(new Intent(this, LoginActivity.class));
            finish();
            return;
        }

        // 已登录，显示Token
        TextView tvInfo = findViewById(R.id.tv_info);
        tvInfo.setText("登录成功！\n你的Token：\n" + tokenManager.getToken());
    }
}